# Python 2.6.4
# Project Euler, Problem 33
# Copyright 2010 Talha Zaman

def cancel(x, y):
    x1, x2, y1, y2 = x/10, x%10, y/10, y%10
    if x1==y1 and x/float(y) == x2/float(y2): return True
    if x1==y2 and x/float(y) == x2/float(y1): return True
    if x2==y1 and x/float(y) == x1/float(y2): return True
    if x2==y2 and x/float(y) == x1/float(y1): return True
    return False

def red(x,y):
    for i in range(2, x+1):
        while (x%i==0 and y%i==0):
            x, y = x/i, y/i
    return [x, y]

num, den = 1, 1
for i in range(11,100):
    for j in range(i+1, 100):
        if i%10==0 or j%10==0: continue
        if cancel(i,j): num, den = num*i, den*j

print red(num, den)
